package cn.edu.answer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.answer.po.Teacher;
import cn.edu.answer.service.TeacherService;
import cn.edu.answer.utils.Page;

@Controller
public class TeacherController {
	@Autowired
	private TeacherService teacherService;
	/**
	 *  教师列表
	 */
	@RequestMapping(value = "/teacher/list.action")
	public String list(@RequestParam(defaultValue="1")Integer page,
			@RequestParam(defaultValue="10")Integer rows, Model model) {
		// 所有学生列表
		Page<Teacher> teachers = teacherService.findTeacherList(page,rows);
		model.addAttribute("page", teachers);	
		System.out.println("===="+teachers.getSize());
		System.out.println("===="+teachers);
		return "teacher_list";
	}
	
	/**
	 * 删除教师信息
	 */
	@RequestMapping("/teacher/deleteTeacher.action")
	@ResponseBody
	public String teacherDelete(String tno) {
	    int rows = teacherService.deleteTeacher(tno);
	    if(rows > 0){			
	        return "OK";
	    }else{
	        return "FAIL";			
	    }
	}
}
